<?php
/**

 //  DoYouHaoBaby-X Ucenter ( DoYouHaoBaby-X 计划 )
 //  +---------------------------------------------------------------------
 //
 //  “Copyright”
 //  +---------------------------------------------------------------------
 //	 | (C) 2010 - 2011 http://doyouhaobaby.net All rights reserved.
 //	 | This is not a free software, use is subject to license terms
 //  +---------------------------------------------------------------------
 //
 //  “About This File”
 //  +---------------------------------------------------------------------
 //	 | Ucenter 配置模型
 //  +---------------------------------------------------------------------

*/

!defined( 'DYHB_PATH' ) && exit;

class OptionModel extends CommonModel{

	/**
	 * 配置数据
	 *
	 * @var array
	 */
	public static $_arrOption=array();


	/**
     * 返回对象的定义
     */
    static public function init__(){

        return array(

            'table_name' => 'option',

            'props' => array(

                // 配置项不变
                'option_name'=>array( 'readonly'=>true ),
            ),

            'check' => array(

            ),

        );

    }


	/**
     * 开启一个查询，查找符合条件的对象或对象集合
     */
    static function F( ){

        $arrArgs = func_get_args();
        return ModelMeta::instance( __CLASS__ )->findByArgs( $arrArgs );
    }


    /**
     * 返回当前 Model 类的元数据对象
     */
    static function M( ){

        return ModelMeta::instance(__CLASS__);
    }


	/**
	 * 初始化配置
	 */
	static public function optionData(   ){

	    $arrOptionData = self::F(  )->asArray()->all()->query();

        if( $arrOptionData===false ) return false;

        foreach( $arrOptionData as $nKey =>$arrValue ){

            $arrOptionData[ $arrValue['option_name'] ]=$arrValue['option_value'];
			unset( $arrOptionData[ $nKey ]  );
        }

		return self::$_arrOption = $arrOptionData;
	}


}
